<?php
$width=Yii::app()->params['dialog']['findTruckForOdometerNo']['width'];
$height=Yii::app()->params['dialog']['findTruckForOdometerNo']['height'];
$cs=Yii::app()->clientScript;
$cs->registerScriptFile('./js/modal.js');
$cs->registerScript('truck_odometer_dialog',<<<END
function Block(){
 \$.modal('?r=dialog/findTruckForOdometerNo&odom_date='+$("#odom_date").val(),{width:$width,height:$height,title:"请选择车辆"});return false;}
$("#findTruck").click(Block);
var truck_odom;
function check_truck_odom(){
	var vaild=true;
	var validator=$("form").validate();
	vaild=validator.element($('#Odometer_no_plate_no'))?vaild:false;
	vaild=validator.element($('#odom_date'))?vaild:false;
	if(!vaild)return;
	$.ajax({'type':'POST','url':'?r=odometer_no/checkTruckOdom','async':false,'cache':false,'data':'plate_no='+$("#Odometer_no_plate_no").val()+'&odom_date='+$("#odom_date").val(),'success':function(data){truck_odom=data;}});
	if(truck_odom!=1) {alert("此车辆"+$("#odom_date").val()+"表公里读数已添加!");return false;}
	return true;
}
if(!'$update') $('form').submit(check_truck_odom);
END
)
?>
<div class="yiiForm">
<?php
	echo EHtml::form();	
	EHtml::setOptions(array('errorElement'=> 'span'));
	EHtml::setScenario($update ? 'update' : 'create');				  		
?>
<div>注：<span class="required">*</span>为必填项</div>
<div id="leftaa" style="border-bottom:0px;">
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'odom_date'); ?>
<?php $arr=array('id'=>'odom_date','size'=>7); if($update) $arr+=array('value'=>substr($model->odom_date,0,7),'class'=>'readonly','readOnly'=>'true'); echo EHtml::activeTextField($model,'odom_date',$arr); ?>
<?php if(!$update) $this->widget('application.extensions.calendar.SCalendar',array('inputField'=>'odom_date','ifFormat'=>'%Y-%m',));?>
</div>
<div class="simple1">
<?php echo CHtml::activeLabelEx($model,'plate_no'); ?>
<?php echo EHtml::activeTextField($model,'plate_no',array('size'=>7,'class'=>'readonly','readOnly'=>'true')); ?>
<?php if(!$update):?>&nbsp;&nbsp;<a id="findTruck" href="#">查找车辆</a><?php endif;?>
</div>
</div>
<div id="rightaa" style="border-bottom:0px;">
<div class="simple"></div>
<div class="simple1">
<?php echo CHtml::activeLabelEx($model,'eom_no'); ?>
<?php echo EHtml::activeTextField($model,'eom_no',array('size'=>10)); ?>
</div>
</div>
<div class="action">
<?php echo EHtml::submitButton($update ? '更新信息' : '添加信息'); ?>
</div>

<?php echo EHtml::endForm(); ?>

</div><!-- yiiForm -->
<?php 
if($model->hasErrors()) echo "<script>alert('您填写的信息有误！请根据页面红色图标提示修改。');</script>";
?>